Ext.override(Ext.form.BasicForm,{
	loadRecord : function(record){
		this.trackResetOnLoad = true;
        this.setValues(record.data);
        this.trackResetOnLoad = false;
        return this;
    },
    cleanRecord:function(){
    	this.items.each(function(f){
           f.originalValue=null;
        });
    }
});
/**
 * 重写Ext.form.TextField的字符串长度验证
 * 一个中文算2个字符长度
 * 适用于Extjs 2.3
 */
Ext.override(Ext.form.TextField,{
 validateValue: function(value){
        if(value.length < 1 || value === this.emptyText){ // if it's blank
             if(this.allowBlank){
                 this.clearInvalid();
                 return true;
             }else{
                 this.markInvalid(this.blankText);
                 return false;
             }
        }
        var valueLength=fucCheckLength(value);
        if(valueLength< this.minLength){
            this.markInvalid(String.format(this.minLengthText+',实际输入长度  '+valueLength, this.minLength));
            return false;
        }
        if(valueLength> this.maxLength){
            this.markInvalid(String.format(this.maxLengthText+',实际输入长度  '+valueLength, this.maxLength));
            return false;
        }
        if(this.vtype){
            var vt = Ext.form.VTypes;
            if(!vt[this.vtype](value, this)){
                this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
                return false;
            }
        }
        if(typeof this.validator == "function"){
            var msg = this.validator(value);
            if(msg !== true){
                this.markInvalid(msg);
                return false;
            }
        }
        if(this.regex && !this.regex.test(value)){
            this.markInvalid(this.regexText);
            return false;
        }
        return true;
    }
});

/**计算字符串长度，1个中文=2个字符长度*/
function fucCheckLength(strTemp) {
 var i, sum;
 sum = 0;
 for (i = 0; i < strTemp.length; i++) {
  if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255))
   sum = sum + 1;
  else
   sum = sum + 2;
 }
 return sum;
}